import basegraphunit from './basegraphunit.js'
import coorPkg from '../../struct/coord.js'

class Arc extends basegraphunit.BaseGraphUnit {
    constructor() {
        super();
        this.pos = new coorPkg.ArcPos();
        this.radius = 0;
        this.x = 0;
        this.y = 0;
        this.stAngle = 0;//角度值
        this.endAngle = 0;
        this.antiClockWise = true;//默认逆时针绘制
        this.close = false;
    }

    translateSubInfo(tx,ty){
        this.x += tx;
        this.y += ty;
    }

    toJson() {
        var jsonobj = {};
        super.toJson(jsonobj);
        jsonobj["x"] = this.x;
        jsonobj["y"] = this.y;
        jsonobj["radius"] = this.radius;
        jsonobj["stAngle"] = this.stAngle;
        jsonobj["endAngle"] = this.endAngle;
        jsonobj["antiClockWise"] = this.antiClockWise;
        jsonobj["close"] = this.close;
        return jsonobj;
    }
    fromJson(obj) {
        super.fromJson(obj);
        this.x = obj["x"];
        this.y = obj["y"];
        this.radius = obj["radius"];
        this.stAngle = obj["stAngle"];
        this.endAngle = obj["endAngle"];
        this.antiClockWise = obj["antiClockWise"];
        this.close = obj["close"];

        this.pos.x = this.x;
        this.pos.y = this.y;
        this.pos.radius = this.radius;
        this.pos.stAngle = this.stAngle;
        this.pos.endAngle = this.endAngle;
        this.pos.antiClockWise = this.antiClockWise;
    }

    cloneCopy() {
        var pNewInfo = new Arc();
        super.cloneCopy(pNewInfo);
        pNewInfo.x = this.x;
        pNewInfo.y = this.y;
        pNewInfo.radius = this.radius;
        pNewInfo.stAngle = this.stAngle;
        pNewInfo.endAngle = this.endAngle;
        pNewInfo.antiClockWise = this.antiClockWise;
        pNewInfo.close = this.close;
        return pNewInfo;
    }
}

export default { Arc }